package com.probiz.estore.system.dao.impl;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;

import com.probiz.estore.common.model.system.PaymentHistory;
import com.probiz.estore.core.dao.impl.HibernateGenericDaoImpl;
import com.probiz.estore.core.model.BaseObject;
import com.probiz.estore.system.dao.PaymentHistoryDao;


/**
 * PaymentHistory Data Access Object (DAO) implementation.
 * Developer introduced interfaces should be declared here. Won't get overwritten.
*/
public class PaymentHistoryDaoImpl extends HibernateGenericDaoImpl<PaymentHistory> implements PaymentHistoryDao {
	

	@Override
	protected void initFilterHqlMap() {
		filterHqlMap.put(BaseObject.FilterHqlName.DEFAULT, "select s from PaymentHistory s ");
	}
	
    
    /*
     * (non-Javadoc)
     * @see com.probiz.estore.system.dao.PaymentHistoryDao#getIsExistPaymentHistory(java.lang.String, java.lang.String, java.lang.Integer, java.math.BigDecimal, java.lang.Short)
     */
    public boolean getIsExistPaymentHistory(String flowNo,String orderNo,Integer paymentGatewayId,BigDecimal amount,Short flag){
//    	amount = amount.setScale(2, RoundingMode.UP);
    	String hql="from PaymentHistory ph where ph.flowNo = ? and ph.orderNo=? and ph.paymentGatewayId=? and ph.flag=?";
    	List list=findByHql(hql, new Object[]{flowNo,orderNo,paymentGatewayId,flag});
    	if(list.size()>0) return true;
    	return false;
    }
    
}